package com.huluobo.a2107kotlinshopping.db

import android.content.Context
import androidx.room.Room

/**
 *  Created by LC on 2023/11/14.
 */
class DatabaseUtil {
    companion object {
        private lateinit var database: AppDatabase

        fun init(context: Context) {
            database = Room.databaseBuilder(context, AppDatabase::class.java, "shopping.db")
                .allowMainThreadQueries()//能让数据库一直在主线程查询,公司中不推荐这么做,但是考试可以
                .build()
        }

        fun getDb(): AppDatabase = database
    }
}